<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>watch</title>
</head>
<body>
  <div id="root">
    <input type="text" v-model="firstname">
    <input type="text" v-model="lastname">
    全名：{{fullname}}
  </div>

  <script src="./libs/vue.js"></script>
  <script>
    const vm = new Vue({
      el: '#root',
      data: {
        firstname: '小明',
        lastname: '吴',
        fullname: '吴小明'
      },
      watch: {
        firstname(newValue, oldValue) {
          // this.fullname = this.lastname + newValue
          this.fullname = this.lastname + this.firstname
        },
        lastname() {
          this.fullname = this.lastname + this.firstname
        }
      }
    })
  </script>
</body>
</html>